﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Satire.Common
{
    public class LexToken
    {
        public LexToken(int id, int offsetStart, int offsetEnd, string content)
        {
            _id = id;
            _offsetStart = offsetStart;
            _offsetEnd = offsetEnd;
            _content = content;
        }
        public LexToken(int id, int offsetStart, int offsetEnd)
        {
            _id = id;
            _offsetStart = offsetStart;
            _offsetEnd = offsetEnd;
        }

        public LexToken(int id)
        {
            _id = id;
        }

        public int Id { get { return _id; } }
        public int OffsetStart { get { return _offsetStart; } }
        public int OffsetEnd { get { return _offsetEnd; } }

        #region private
        private int _id = -1;
        private int _offsetStart = -1;
        private int _offsetEnd = -1;
        private string _content = null;
        #endregion
    }
    public enum LexTableAction { ACCEPT, ERROR, GOTO, IGNORE }

    interface ILexTable 
    {
        int FirstState();
        LexTableAction NextState(ref int data, int c);
    }

    interface ILexTableBuilder
    {
        void reset();
        void add(string re, int id);
        void add(string re);
        void addMacro(string re, string name);
        ILexTable generate();
    }

    interface ILexEngine
    {
        void setTable(ILexTable lt);
        LexToken GetToken(TextReader tr, bool greedy, bool returnAll);
    }
}
